package net.basshista.jsshtunneling.beans;

import java.io.Serializable;
import java.util.ResourceBundle;

import com.jcraft.jsch.UserInfo;

public class HostBean implements UserInfo, Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -6351825669626638833L;

    public static final String RESOURCE_NAME = "messages";

    public static final String PROMPT_PASSPHRASE = "promptPassphrase";
    public static final String PROMPT_PASSWORD = "promptPassword";

    protected static final ResourceBundle BUNDLE;

    static {
	BUNDLE = ResourceBundle.getBundle(RESOURCE_NAME);
    }

    protected String host;
    protected String user;
    protected int port;
    protected String pass;

    public HostBean() {
    }

    public HostBean(String host, String user, int port, String pass) {
	this.host = host;
	this.user = user;
	this.port = port;
	this.pass = pass;
    }

    public String getHost() {
	return host;
    }

    public void setHost(String host) {
	this.host = host;
    }

    public String getUser() {
	return user;
    }

    public void setUser(String user) {
	this.user = user;
    }

    public int getPort() {
	return port;
    }

    public void setPort(int port) {
	this.port = port;
    }

    public String getPass() {
	return pass;
    }

    public void setPass(String pass) {
	this.pass = pass;
    }

    @Override
    public String toString() {
	return "HostBean [host=" + host + ", user=" + user + ", port=" + port + ", pass=" + pass + "]";
    }

    @Override
    public String getPassphrase() {
	return null;
    }

    @Override
    public String getPassword() {
	return this.pass;
    }

    @Override
    public boolean promptPassword(String message) {
	return true;
    }

    @Override
    public boolean promptPassphrase(String message) {
	return true;
    }

    @Override
    public boolean promptYesNo(String message) {
	return true;
    }

    @Override
    public void showMessage(String message) {
	// TODO Auto-generated method stub

    }

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((host == null) ? 0 : host.hashCode());
	result = prime * result + ((pass == null) ? 0 : pass.hashCode());
	result = prime * result + port;
	result = prime * result + ((user == null) ? 0 : user.hashCode());
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	HostBean other = (HostBean) obj;
	if (host == null) {
	    if (other.host != null)
		return false;
	} else if (!host.equals(other.host))
	    return false;
	if (pass == null) {
	    if (other.pass != null)
		return false;
	} else if (!pass.equals(other.pass))
	    return false;
	if (port != other.port)
	    return false;
	if (user == null) {
	    if (other.user != null)
		return false;
	} else if (!user.equals(other.user))
	    return false;
	return true;
    }

}